<template>
    <div class="banner">
        <van-swipe class="swipe" :autoplay="3000" indicator-color="white">
            <van-swipe-item v-for="(item,index) in vueState.pageInfo.banner" :key="index" @click="clickBanner(item,index+1)">
                <div class="banner-wrapper">
                    <yowin-img :src="item.image" :default-img="'https://cdn.yowin.mobi/pub/uploadFile/other/d8df35db57f14473a835a52d07d581de.svg'"></yowin-img>
                </div>
            </van-swipe-item>
        </van-swipe>
    </div>
</template>
<script>
import { inject } from 'vue'
import {changeURLArg} from '@@/utils/common.js'
export default {
    setup(props) {
        const vueState = inject('vueState')
        const clickBanner = (item,index)=> {
            window.SDKPostMessage({
                event:'h5_open_page',
                data:{
                    target:'webview',
                    data:{
                        url:changeURLArg(changeURLArg(changeURLArg(item.landingPage,'source','mePage'),'headers',encodeURIComponent(JSON.stringify(vueState.pageInfo.header))),'ts',new Date().getTime()),
                        title:'',
                        closable:false,
                    }
                }
            })
            window.trackEvent({ev:'clickBanner',remarks:`Order:${index},URL:${item.landingPage},landtype:${item.clickType}`})
        }
        return {
            vueState,
            clickBanner,
        }
    }
}
</script>
<style lang="less" scoped>
.banner{
    width: 100%;
    .swipe{
        width: 100%;
    }
    &-wrapper{
        height: .82rem;
        border-radius: .08rem;
    }
}
</style>